﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FocusOnTerrain
{
    public class HeightMap
    {
        public HeightMap(int sizex, int sizey)
        {
            if (sizex > 0 && sizey > 0)
            {
                mSizeX = sizex;
                mSizeY = sizey;
                mHeightMap = new float[mSizeX * mSizeY];
            }
        }

        public float this[int x, int y]
        {
            get
            {
                if (x >= 0 && x < SizeX && y >= 0 && y < SizeY)
                {
                    int index = x * this.SizeX + y;
                    return mHeightMap[index];
                }
                return 0;
            }
            set
            {
                if (x >= 0 && x < SizeX && y >= 0 && y < SizeY)
                {
                    int index = x * this.SizeX + y;
                    mHeightMap[index] = value;
                }
            }
        }
        public int SizeX
        {
            get
            {
                return this.mSizeX;
            }
        }
        public int SizeY
        {
            get
            {
                return this.mSizeY;
            }
        }        
        private float[] mHeightMap = null;
        private int mSizeX = 0;
        private int mSizeY = 0;
    }
}
